package jdbc;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

public class UPDATE {
    public static void main(String[] args) {
        try (
         Connection connection = DBUtil.getConnection();
         ){
            Statement statement = connection.createStatement();
            String sql = "UPDATE user SET name='徐家源' WHERE name='小徐'";
            int num = statement.executeUpdate(sql);
            if(num>0){//说明至少影响了表中1条记录
                System.out.println("修改成功");
            }else{
                System.out.println("修改失败");
            }
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }


    }
}
